<?php
// +----------------------------------------------------------------------
// | 知识星球[基于ThinkPHP5开发]
// +----------------------------------------------------------------------
// | Copyright (c) 2018-2019 abcblockchain.io
// +----------------------------------------------------------------------
// | 后台管理使用了HisiPHP
// +----------------------------------------------------------------------
// | Author: abcblockchain.io
// +----------------------------------------------------------------------
namespace app\api\home;

use app\common\controller\Api;
use think\Db;
use app\common\model\Message as msgModel;

class Msg extends Api
{
    /**
     * 获取评论消息列表
     * @author
     */
    public function getCommentList()
    {
        $postData = $this->requestData;
        if (isset($postData['userId']) && $postData['userId'] > 0) {
            $msgModel = new msgModel();
            $page = isset($postData['nowPage']) ? $postData['nowPage'] : 0;
            $msgList = $msgModel->getMsg($postData['userId'],2,$page);
            $result = array(
                'status' => 1,
                'data' => $msgList,
                'code' => 0,
            );
        }else{
            $result = array(
                'status' => 0,
                'data' => 'param error',
                'code' => 1,
            );
        }
        echo json_encode($result);
        exit();
    }

    /**
     * 获取最新评论
     * @author
     */
    public function getLastComment(){
        $postData = $this->requestData;
        if (isset($postData['userId']) && $postData['userId'] > 0) {
            $msgModel = new msgModel();
            $page = 0;
            $msgList = $msgModel->getMsg($postData['userId'],2,$page,1);
            $result = array(
                'status' => 1,
                'data' => $msgList,
                'code' => 0,
            );
        }else{
            $result = array(
                'status' => 0,
                'data' => 'param error',
                'code' => 1,
            );
        }
        echo json_encode($result);
        exit();
    }
}